package org.forever.util
{
	/**
	* 基于邻接边表实现图的顶点结构
	*/
	public class Vertex_List implements Vertex
	{
		public var info:Object;//当前顶点中存放的数据元素
		public var vPosInV:Position;//当前顶点在所属的图的顶点表V中的位置
		public var outEdges:List;//关联边表：存放以当前顶点为尾的所有边（的位置）
		public var inEdges:List;//关联边表：存放以当前顶点为头的所有边（的位置）
		public var status:int;//（在遍历图等操作过程中）顶点的状态
		public var dStamp:int;//时间标签：DFS过程中该顶点被发现时的时刻
		public var fStamp:int;//时间标签：DFS过程中该顶点被访问结束时的时刻
		public var distance:int;//到指定起点的距离：BFS、Dijkstra等算法所确定该顶点到起点的距离
		public var bfsParent:Vertex;//在最短距离树（BFS或BestFS）中的父亲
		 
		//构造方法：在图G中引入一个属性为x的新顶点
		public function Vertex_List(G:Graph,x:Object)
		{
			info = x;//数据元素
			vPosInV = G.insertV(this);//当前顶点在所属的图的顶点表V中的位置
			outEdges = new List_DLNode();//出边表
			inEdges = new List_DLNode();//入边表
			status = UNDISCOVERED;
			dStamp = fStamp = Number.MAX_VALUE;
			distance = Number.MAX_VALUE;
			bfsParent = null;
		}
		
		public function getInfo():Object
		{
			return info;
		}
		
		public function setInfo(x:Object):Object
		{
			var e:Object = info; info = x; return e;
		}
		
		public function outDeg():int
		{
			return outEdges.getSize();
		}
		
		public function inDeg():int
		{
			return inEdges.getSize();
		}
		
		public function getInEdges():Iterator
		{
			return inEdges.elements();
		}
		
		public function inEdgePositions():Iterator
		{
			return inEdges.positions();
		}
		
		public function getOutEdges():Iterator
		{
			return outEdges.elements();
		}
		
		public function outEdgePositions():Iterator
		{
			return outEdges.positions();
		}
		
		
		public function getVPosInV():Position
		{
			return vPosInV;
		}
		
		public function getStatus():int
		{
			return status;
		}
		
		public function setStatus(s:int):int
		{
			var ss:int = status; status = s; return ss;
		}
		
		public function getDStamp():int
		{
			return dStamp; 
		}
		
		public function setDStamp(s:int):int
		{
			var ss:int = dStamp; dStamp = s; return ss;
		}
		
		public function getFStamp():int
		{
			return fStamp; 
		}
		
		public function setFStamp(s:int):int
		{
			var ss:int = fStamp; fStamp = s; return ss;
		}
		
		public function getDistance():int
		{
			return distance; 
		}
		
		
		public function setDistance(s:int):int
		{
			var ss:int = distance; distance = s; return ss;
		}
		
		public function getBFSParent():Vertex
		{
			return bfsParent;
		}
		
		public function setBFSParent(s:Vertex):Vertex
		{
			var ss:Vertex = bfsParent; bfsParent = s; return ss;
		}
	}
}